package com.itheima.test4lambdawucanyoufan;

import java.util.Random;

public class Demo6 {
    public static void main(String[] args) {
        useRandomHandler(new RandomHandler() {
            @Override
            public int getNumber() {
                Random r = new Random();
                int num = r.nextInt(10)+1;
                return num;
            }
        });
        System.out.println("-----------------");
        useRandomHandler(()->{
            Random r = new Random();
            int num = r.nextInt(10)+1;
            return num;});
    }

    public static void useRandomHandler(RandomHandler randomHandler) {
        int number = randomHandler.getNumber();
        System.out.println(number);
    }
}
interface RandomHandler{
    int getNumber();
}
